﻿
@section styles{

}
@using FwProject.Com.Dto
@using FwProject.ShoppingMall.Com
@model ShopOrderHandleDto

<style>
    .layui-table td, .layui-table th {
        position: relative;
        padding: 9px 15px;
        min-height: 20px;
        line-height: 20px;
        font-size: 14px;
    }

    .first {
        font-size: 16px;
        color: rgb(255, 153, 0);
        font-weight: 700;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto" style="border:none;">
            <div class="layui-form-item">
                <div class="layui-btn-group">
                    @*<button class="layui-btn">确认订单</button>*@
                    <button type="button" class="layui-btn layui-btn-disabled">确认收款</button>
                    <button type="button" data-type="Ship" class="layui-btn @(Model.ShopOrderDetails.Where(o=>o.DeliveryStatus== FwProject.ShoppingMall.Com.DeliveryStatus.未发货).Any()?"activation":"layui-btn-disabled")">发货</button>
                    <button type="button" data-type="Receipt" class="layui-btn @(Model.ShopOrderDetails.Where(o=>o.DeliveryStatus== FwProject.ShoppingMall.Com.DeliveryStatus.已发货).Any()?"activation":"layui-btn-disabled")">确认收货</button>
                    <button type="button" data-type="AfterSale" class="layui-btn @(Model.ShopOrderDetails.Where(o=>o.DeliveryStatus== FwProject.ShoppingMall.Com.DeliveryStatus.已确认&&o.Returngoods== FwProject.ShoppingMall.Com.Returngoods.未退货).Any()?"activation":"layui-btn-disabled")">售后</button>
                    <button type="button" data-type="Cancel" class="layui-btn activation">取消订单</button>
                </div>
                <div class="layui-layout-right">
                    <a class="layui-btn" href="javascript:void()" onclick="window.open('/Print/TicketPrint?orderId=@Model.Id&userName=@Model.ShopOrderInformation.ShopReceivingAddress.ReceivingName&orderNumber=@Model.ShopOrderInformation.OrderNumber&orderTime=@Model.ShopOrderInformation.CreationTime&mobile=@Model.ShopOrderInformation.ShopReceivingAddress.ReceivingTel&address=@Model.ShopOrderInformation.ShopReceivingAddress.ReceivingAddress')">打印订单</a>
                </div>
            </div>
            </div>

        <div class="layui-fluid">
            <div class="layui-tab-card" lay-allowclose="true">
                <div class="layui-tab layui-tab-brief">
                    <ul class="layui-tab-title" style="border:none;">
                        <li class="layui-this">基本信息</li>
                        <li class="">订单日志</li>
                        <li class="">发票</li>
                    </ul>
                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                                <legend>订单编号：@Model.ShopOrderInformation.OrderNumber</legend>
                            </fieldset>
                            <div class="layui-form">
                                <table id="details" class="layui-table">
                                    @*<colgroup>
                                            <col width="150">
                                            <col width="150">
                                            <col width="200">
                                            <col>
                                        </colgroup>*@
                                    <thead>
                                        <tr>
                                            <th>商品</th>
                                            <th>购买量</th>
                                            <th>单价</th>
                                            <th>发货时间</th>
                                            <th>发货状态</th>
                                            <th>评价状态</th>
                                            <th>结算状态</th>
                                            <th>退货状态</th>
                                            <th>合计</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @if (Model.Id != Guid.Empty)
                                        {
                                            foreach (var item in Model.ShopOrderDetails)
                                            {
                                                <tr>
                                                    <td>@item.ShopName</td>
                                                    <td>@item.ProductCount</td>
                                                    <td>@item.PayPrice</td>
                                                    <td>@(item.DeliveryTime.HasValue ? item.DeliveryTime.Value.ToString("yyyy-MM-dd HH:mm") : "")</td>
                                                    <td>@item.DeliveryStatus</td>
                                                    <td>@item.EvaluateStatus</td>
                                                    <td>@item.SettlementStatus</td>
                                                    <td>@item.Returngoods</td>
                                                    <td>
                                                        @(item.ProductCount * item.PayPrice)
                                                    </td>
                                                </tr>
                                            }
                                        }
                                    </tbody>
                                </table>
                            </div>
                            <div style="padding: 20px; background-color: #F2F2F2;">
                                <div class="layui-row layui-col-space15">
                                    @if (Model.Id != Guid.Empty)
                                    {
                                        <div class="layui-col-md3">
                                            <div class="layui-card">
                                                <div class="layui-card-header"><h2>订单价格</h2></div>
                                                <div class="layui-card-body">
                                                    <table class="layui-table">
                                                        <colgroup>
                                                            <col width="100">
                                                            <col>
                                                        </colgroup>
                                                        <tbody>
                                                            <tr>
                                                                <td style="text-align:center;">订单总额</td>
                                                                <td><span class="first">￥@Model.ShopOrderInformation.PayTotal.ToString("G")</span></td>
                                                            </tr>
                                                            <tr>
                                                                <td style="text-align:center;">优惠金额</td>
                                                                <td><span class="first">￥@Model.ShopOrderInformation.PyaPreferentia.ToString("G")</span></td>
                                                            </tr>
                                                            <tr>
                                                                <td style="text-align:center;">应付金额</td>
                                                                <td><span class="first">￥@Model.ShopOrderInformation.PayAmount.ToString("G")</span></td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md3">
                                            <div class="layui-card">
                                                <div class="layui-card-header"><h2>订单其他信息</h2></div>
                                                <div class="layui-card-body">
                                                    <table class="layui-table">
                                                        <colgroup>
                                                            <col width="100">
                                                            <col>
                                                        </colgroup>
                                                        <tbody>
                                                            <tr>
                                                                <td style="text-align:center;">商品重量</td>
                                                                <td>0g</td>
                                                            </tr>
                                                            <tr>
                                                                <td style="text-align:center;">支付方式</td>
                                                                <td><span class="first">@Model.ShopOrderInformation.PayType </span></td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md3">
                                            <div class="layui-card">
                                                <div class="layui-card-header"><h2>会员信息</h2></div>
                                                <div class="layui-card-body">
                                                    <table class="layui-table">
                                                        <colgroup>
                                                            <col width="100">
                                                            <col>
                                                        </colgroup>
                                                        <tbody>
                                                            <tr>
                                                                <td style="text-align:center;">用户名</td>
                                                                <td>@Model.ShopUser.UserName</td>
                                                            </tr>
                                                            <tr>
                                                                <td style="text-align:center;">姓名</td>
                                                                <td>@Model.ShopUser.Name</td>
                                                            </tr>
                                                            <tr>
                                                                <td style="text-align:center;">电话</td>
                                                                <td>@Model.ShopUser.Mobile</td>
                                                            </tr>
                                                            <tr>
                                                                <td style="text-align:center;">地区</td>
                                                                <td>@Model.ShopUser.NowAddress</td>
                                                            </tr>
                                                            <tr>
                                                                <td style="text-align:center;">Email</td>
                                                                <td>@Model.ShopUser.EmailAddress</td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-md3">
                                            <div class="layui-card">
                                                <div class="layui-card-header"><h2>收货人信息</h2></div>
                                                <div class="layui-card-body">
                                                    <table class="layui-table">
                                                        <colgroup>
                                                            <col width="100">
                                                            <col>
                                                        </colgroup>
                                                        <tbody>
                                                            <tr>
                                                                <td style="text-align:center;">姓名</td>
                                                                <td><span class="first">@Model.ShopOrderInformation.ActualReceivingName</span></td>
                                                            </tr>
                                                            <tr>
                                                                <td style="text-align:center;">电话</td>
                                                                <td><span class="first">@Model.ShopOrderInformation.ActualReceivingTel </span></td>
                                                            </tr>
                                                            <tr>
                                                                <td style="text-align:center;">地区</td>
                                                                @{var add = Model.ShopOrderInformation.ActualReceivingAddress.Split(' '); }
                                                                <td>@(add.Count()>0?add[0] : Model.ShopOrderInformation.ShopReceivingAddress.AreaId)</td>
                                                            </tr>
                                                            <tr>
                                                                <td style="text-align:center;">地址</td>
                                                                <td>@(add.Count() >= 2 ? add[1] : Model.ShopOrderInformation.ShopReceivingAddress.ReceivingAddress)</td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    }
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item" style="">

                        </div>
                        <div class="layui-tab-item" style="">

                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
@section scripts{
    <script src="~/js/main.js"></script>
    <script type="text/javascript">
        var form, layer, layedit, element;
        layui.use(['form', 'layedit', 'layer', 'element'], function () {
            layedit = layui.layedit;
            form = layui.form;
            layer = layui.layer
            element = layui.element;

            var $ = layui.$, active = {
                Ship: function () {
                    LayerOpen("订单发货","/Order/OrderShip?id=@Model.Id")
                }
                , Receipt: function () {
                    LayerOpen("订单收货","/Order/OrderReceipt?id=@Model.Id")
                }
                , AfterSale: function () {
                    LayerOpen("售后申请","/Order/OrderAfterSale?id=@Model.Id")
                }
                , Cancel: function () {
                    layer.confirm('作废操作会使该订单归档且不允许再做任何操作，确定要执行吗？', {
                        btn: ['确定', '取消'] //按钮
                    }, function () {
                        $.post("/Order/OrderCancel", { id: "@Model.Id" }, function (obj, successInfo) {
                            CommonAjaxCallback(obj, function () {
                                layer.closeAll();
                            }, successInfo)
                        })
                    });
                }
            };

            $('.layui-btn-group .activation').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });



            function LayerOpen(title, url) {
                var open = layer.open({
                    type: 2,
                    title: title,
                    shadeClose: true,
                    shade: false,
                    maxmin: true, //开启最大化最小化按钮
                    area: ['700px', '520px'],
                    content: url,
                    success: function (layero, index) {
                        var body = layer.getChildFrame('body', index)//确定两个页面的父子关系
                    },
                    end: function () {
                        //销毁后重新加载
                        //table.reload('idTest', {
                        //    page: {
                        //        curr: 1 //重新从第 1 页开始
                        //    }
                        //})
                    }
                });
            }

        });

    </script>
}